<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="title">#{msgs.Administration_createGroup_pageTitle}</ui:define>
		<ui:define name="manuBar">
			<h:form>
				<p:menubar autoSubmenuDisplay="true" id="menu"
					style="font-size:small">
					<p:menuitem value="#{msgs.Administration_administrationMenu_Home}" immediate="true" ajax="false"
						url="/controlling/index.xhtml" icon="ui-icon-gear"
						onstart="waiteDialog.show()" />
					
					<p:menuitem value="#{msgs.Administration_administrationMenu_AdministrationIndex}"
						url="/controlling/administration/administrationIndex.xhtml"
						icon="ui-icon-gear" immediate="true" onstart="waiteDialog.show();" />
						
					<p:menuitem value="#{msgs.Administration_Group_GroupIndex}" immediate="true" ajax="false"
						url="/controlling/administration/groupIndex.xhtml"
						icon="ui-icon-home" onstart="waiteDialog.show()" />
				</p:menubar>
			</h:form>
		</ui:define>
		<ui:define name="content">
			<h:form
				rendered="#{registeredUser.hasPrivilege(1) or registeredUser.hasPrivilege(2)}">
				<p:panel header="#{msgs.Administration_Group_CreateNewGroup}" id="createNewGroup_id">
					<h:panelGrid columns="2">
						<h:outputText value="#{msgs.Administration_Group_GroupId}"
							rendered="#{groupBean.group.recid !=null}" />
						<h:outputText value="#{groupBean.group.recid}"
							rendered="#{groupBean.group.recid !=null}" />
						
						<h:outputText value="#{msgs.Administration_Group_GroupName}" />
						<p:inputText value="#{groupBean.group.name}" required="true"
							requiredMessage="#{msgs.Administration_Group_GroupNameRequired}" id="groupName" size="24" />

						<h:outputText value="#{msgs.Administration_Group_GroupStatus}" />
						<p:selectOneMenu value="#{groupBean.group.status}"
							style="font:small;">
							<f:selectItem itemValue="1" itemLabel="Active" />
							<f:selectItem itemValue="0" itemLabel="InActive" />
						</p:selectOneMenu>

					</h:panelGrid>
					<br />
					<p:dataTable id="table_privileges"
						value="#{groupBean.privilegeMappingList}"
						var="privilegeMap" paginator="true" rows="10">
						<p:column headerText=" #{msgs.Administration_Group_PrivilegeName}" style="width:auto">
							<h:outputText value="#{privilegeMap.privilegeName}" />
						</p:column>
						<p:column headerText="#{msgs.Administration_Group_Access}" style="width:auto">
							<p:selectOneMenu value="#{privilegeMap.accessId}"
								style="font:small;" required="true">
								<f:selectItem itemValue="-1" itemLabel="" />
								<f:selectItems
									value="#{groupBean.accessList}" var="access"
									itemLabel="#{access.name}" itemValue="#{access.recid}" />
							</p:selectOneMenu>
						</p:column>
					</p:dataTable>

					<br />
					<p:commandButton value="#{msgs.Administration_General_Save}"
						actionListener="#{groupBean.saveGroupWithPrivileges}"
						onstart="waiteDialog.show()" oncomplete="waiteDialog.hide()"
						update="gr_messages" style="height: 30px;font-size: small" />

					<p:commandButton value="Back" action="#{groupBean.toGroupIndex}"
						immediate="true" onstart="waiteDialog.show()"
						style="height: 30px;font-size: small" />

					<p:messages id="gr_messages" showDetail="true" showSummary="true" />

				</p:panel>

			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>

